#include <iostream>
#include <unordered_map>
#include <unordered_set>

using namespace std;

class Solution {
public:
    bool isIsomorphic(string s, string t) {
        unordered_map<char, char> map;
        unordered_set<char> dist_map;
        for (int i = 0; i < s.size(); i++) {
            if (map.count(s[i]) == 0) {
                if (dist_map.count(t[i]) == 0) {
                    map[s[i]] = t[i];
                    dist_map.insert(t[i]);
                } else {
                    return false;
                }
            } else {
                char dist = map[s[i]];
                if (dist != t[i]) {
                    return false;
                }
            }
        }
        return true;
    }
};

int main() {
    Solution solution;
    bool output = solution.isIsomorphic("aa", "ab");
    cout << output << endl;
    return 0;
}